/**
 * 
 */
package com.runningfox.humor;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

import com.runningfox.logic.DataBase;
import com.runningfox.model.Setting;

/**
 * @author luhaiyang
 * 
 */
public class Start extends Activity {
	String PREFS_NAME = "setting";
	WifiManager wifiMgr ;
	LocationManager locationMgr;
	Context c;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		Window win = getWindow();
		win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 0);
//		win.setFlags(WindowManager.LayoutParams.NO_STATUS_BAR_FLAG,
//				WindowManager.LayoutParams.NO_STATUS_BAR_FLAG);
		setContentView(R.layout.launch);
		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				// inint system propertys
				c=Start.this.getApplicationContext();
				initSettings();
				// init database
				initDataBase();
				
				initWifi();

//				initLocale();
//				initBluetooth();
				Intent intent = new Intent(Start.this, Humor.class);
				startActivity(intent);
				finish();
			}
		}, 300);
	}

//	void initLocale(){
//		locationMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
//	}
	
//	void initBluetooth(){
//		
//		BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
//		if (mBluetoothAdapter == null) {
//		    // Device does not support Bluetooth
//		}else{
//			String name = mBluetoothAdapter.getName();
//			Log.d("bluetooth", name);
//		}
//	}
	void initWifi(){
		try{
			wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE);
			WifiInfo info = wifiMgr.getConnectionInfo();
			Setting.wifi=info.getSSID();
			Log.v("wifi", Setting.wifi);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	void initDataBase() {
		DataBase db = new DataBase(this.getApplicationContext());
		db.initDatabase();
	}

	void initSettings() {
		Setting.LoadSetting(this);
	}
}
